// if(true){
//     let foo = 123
// }
// console.log(foo)//foo is not defined
// for(let i=0;i<3;i++){
//     for(let i=0;i<3;i++){
//       console.log(i)
//     }
//     console.log("内层"+i)
// }
// const arr = [100,200,300,4]
// const [foo,bar,baz] = arr;
// console.log(foo,bar,baz)//100 200 300
// const [foo,...reset] = arr;
// console.log(reset)// [ 200, 300, 4 ]
// reset 从当前位置往后的所有成员，并把他们放到一个数组中。注意：只能在我们解构的最后一个位置用。
// const [foo,bar,baz,boo,coo = "defu"] = arr;
// console.log(coo)//undefined
// const path = "foo/bar/baz"
// const [,str] = path.split("/")
// console.log(str)

// const sy = Symbol("key1")
// const sy1 = Symbol("key2")
// const obj = {
//     [sy1]:"ee",
//     name:1,
//     age:19
// }
// obj[sy] = "kk"
// Object.keys(obj)
// Object.getOwnPropertySymbols(obj)
// Reflect.ownKeys(obj)
// console.log(Reflect.ownKeys(obj))
const COLOR_RED = "red";
const COLOR_YELLOW = "yellow";
const COLOR_BLUE = "blue";
const MY_BLUE = "blue";
 
function ColorException(message) {
   this.message = message;
   this.name = "ColorException";
}
 
function getConstantName(color) {
    switch (color) {
        case COLOR_RED :
            return "COLOR_RED";
        case COLOR_YELLOW :
            return "COLOR_YELLOW ";
        case COLOR_BLUE:
            return "COLOR_BLUE";
        case MY_BLUE:
            return "MY_BLUE";         
        default:
            throw new ColorException("Can't find this color");
    }
}
 
try {
   
   var color = "green"; // green 引发异常
   var colorName = getConstantName(color);
} catch (e) {
   var colorName = "unknown";
   console.log(e.message, e.name); // 传递异常对象到错误处理
}
